from accounts.models import SocialAnimal
from django.contrib import admin
from admin_widgets import AdminImageWidget

class SocialAnimalAdmin(admin.ModelAdmin):
    def formfield_for_dbfield(self, db_field, **kwargs):
        if db_field.name == 'avatar':
            request = kwargs.pop("request", None)
            kwargs['widget'] = AdminImageWidget
            return db_field.formfield(**kwargs)
        return super(SocialAnimalAdmin,self).formfield_for_dbfield(db_field, **kwargs)

admin.site.register(SocialAnimal, SocialAnimalAdmin)
